<template>
	<div>
		<el-form ref="form" :model="form" label-width="80px">
			<el-form-item label="账号">
				<el-input v-model="form.username"></el-input>
			</el-form-item>
			<el-form-item label="密码">
				<el-input v-model="form.password"></el-input>
			</el-form-item>

			<el-form-item>
				<el-button type="primary" @click="onSubmit">登录</el-button>
				<el-button>取消</el-button>
				
				<el-button type="primary" @click="reg()">免费注册</el-button>
			</el-form-item>
		</el-form>
	</div>
</template>

<script>
	import axios from "axios"

	export default {
		data() {
			return {
				form: {
					username: '',
					password: ''
				}
			}
		},
		methods: {
			onSubmit() {
				console.log('submit!');
				axios.post('http://localhost:20010/api-store/api/user-store/login', this.form).then(res => {
					if (res.data.code == 1) {
						this.$message({
							message: '恭喜你，登录成功',
							type: 'success'
						});
						this.$router.push({
							path:"/index"
						})
						
					}else{
						 this.$message.error(res.data.message);
					}
				})
			},
			reg(){
				this.$router.push({
					path:"/reg"
				})
			}
		}
	}
</script>

<style>
</style>